import java.io.*;

public class SerializeDemo {
    public static void main(String[] args) throws Exception {
        Person p = new Person("王奔", 36, "female", 30000.0);


        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("d:/person.obj"));
        os.writeObject(p);
        os.close();


        DataOutputStream dout = new DataOutputStream(new FileOutputStream("d:/p.obj"));
        dout.writeUTF(p.getName());
        dout.writeInt(p.getAge());
        dout.writeUTF(p.getSex());
        dout.writeDouble(p.getSalary());
        dout.close();


        DataOutputStream dout2 = new DataOutputStream(new FileOutputStream("d:/x.obj"));
        dout2.writeUTF("aaa");
        dout2.writeInt(4);

        DataInputStream in = new DataInputStream(new FileInputStream("d:/x.obj"));
        String s = in.readUTF();
        int i = in.readInt();
        System.out.println(s);
        System.out.println(i);

    }
}
